---
title: AppleAuthentication
description: A library that provides Sign-in with Apple capability for iOS.
sourceCodeUrl: 'https://github.com/expo/expo/tree/sdk-53/packages/expo-apple-authentication'
packageName: 'expo-apple-authentication'
platforms: ['ios', 'tvos']
---

import APISection from '~/components/plugins/APISection';
import { APIInstallSection } from '~/components/plugins/InstallSection';
import { ConfigReactNative, ConfigPluginExample } from '~/ui/components/ConfigSection';
import { SnackInline } from '~/ui/components/Snippet';

`expo-apple-authentication` provides Apple authentication for iOS. It does not yet support Android or web.

Any app that includes third-party authentication options **must** provide Apple authentication as an option to comply with App Store Review guidelines. For more information, see Apple authentication on the [Sign In with Apple](https://developer.apple.com/sign-in-with-apple/) website.

## Installation

<APIInstallSection />

## Configuration in app config

You can configure `expo-apple-authentication` using its built-in [config plugin](/config-plugins/introduction/) if you use config plugins in your project ([Continuous Native Generation (CNG)](/workflow/continuous-native-generation/)). The plugin allows you to configure various properties that cannot be set at runtime and require building a new app binary to take effect. If your app does **not** use CNG, then you'll need to manually configure the library.

### Setup iOS project

To enable the **Sign In with Apple** capability in your app, set the [`ios.usesAppleSignIn`](../config/app/#usesapplesignin) property to `true` in your project's app config:

```json app.json
{
  "expo": {
    "ios": {
      "usesAppleSignIn": true
    }
  }
}
```

<ConfigPluginExample>

Running [EAS Build](/build/introduction) locally will use [iOS capabilities signing](/build-reference/ios-capabilities) to enable the required capabilities before building.

```json app.json
{
  "expo": {
    "plugins": ["expo-apple-authentication"]
  }
}
```

</ConfigPluginExample>

<ConfigReactNative>

Apps that don't use [EAS Build](/build/introduction) must [manually configure](/build-reference/ios-capabilities#manual-setup) the **Apple Sign In** capability for their bundle identifier.

If you enable the **Apple Sign In** capability through the [Apple Developer Console](/build-reference/ios-capabilities#apple-developer-console), then be sure to add the following entitlements in your **ios/[app]/[app].entitlements** file:

```xml
<key>com.apple.developer.applesignin</key>
<array>
  <string>Default</string>
</array>
```

Also, set `CFBundleAllowMixedLocalizations` to `true` in your **ios/[app]/Info.plist** to ensure the sign-in button uses the device locale.

</ConfigReactNative>

## Usage

<SnackInline label="Apple Authentication Usage" dependencies={['expo-apple-authentication']} platforms={['ios']}>

```jsx
import * as AppleAuthentication from 'expo-apple-authentication';
import { View, StyleSheet } from 'react-native';

export default function App() {
  return (
    <View style={styles.container}>
      <AppleAuthentication.AppleAuthenticationButton
        buttonType={AppleAuthentication.AppleAuthenticationButtonType.SIGN_IN}
        buttonStyle={AppleAuthentication.AppleAuthenticationButtonStyle.BLACK}
        cornerRadius={5}
        style={styles.button}
        onPress={async () => {
          try {
            const credential = await AppleAuthentication.signInAsync({
              requestedScopes: [
                AppleAuthentication.AppleAuthenticationScope.FULL_NAME,
                AppleAuthentication.AppleAuthenticationScope.EMAIL,
              ],
            });
            // signed in
          } catch (e) {
            if (e.code === 'ERR_REQUEST_CANCELED') {
              // handle that the user canceled the sign-in flow
            } else {
              // handle other errors
            }
          }
        }}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
  button: {
    width: 200,
    height: 44,
  },
});
```

</SnackInline>

## Development and testing

You can test this library in Expo Go on iOS without following any of the instructions above.
However, you'll need to add the config plugin to use this library if you are using EAS Build.
When you sign into Expo Go, the identifiers and values you receive will likely be different than what you'll receive in standalone apps.

You can do limited testing of this library on the iOS Simulator. However, not all methods will behave the same as on a device,
so we highly recommend testing on a real device when possible while developing.

## Verifying the Response from Apple

Apple's response includes a signed JWT with information about the user. To ensure that the response came from Apple,
you can cryptographically verify the signature with Apple's public key, which is published at https://appleid.apple.com/auth/keys.
This process is not specific to Expo.

## API

```js
import * as AppleAuthentication from 'expo-apple-authentication';
```

<APISection packageName="expo-apple-authentication" apiName="AppleAuthentication" />

## Error codes

Most of the error codes match the official [Apple Authorization errors](https://developer.apple.com/documentation/authenticationservices/asauthorizationerror/code).

| Code                        | Description                                                                         |
| --------------------------- | ----------------------------------------------------------------------------------- |
| ERR_INVALID_OPERATION       | An invalid authorization operation has been performed.                              |
| ERR_INVALID_RESPONSE        | The authorization request received an invalid response.                             |
| ERR_INVALID_SCOPE           | An invalid [`AppleAuthenticationScope`](#appleauthenticationscope) was passed in.   |
| ERR_REQUEST_CANCELED        | The user canceled the authorization attempt.                                        |
| ERR_REQUEST_FAILED          | The authorization attempt failed. See the error message for additional information. |
| ERR_REQUEST_NOT_HANDLED     | The authorization request wasn't correctly handled.                                 |
| ERR_REQUEST_NOT_INTERACTIVE | The authorization request isn't interactive.                                        |
| ERR_REQUEST_UNKNOWN         | The authorization attempt failed for an unknown reason.                             |
